﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>FixedColumns 锁定列</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" />

    
    <script src="../../scripts/boot.js" type="text/javascript"></script>
    
        
</head>
<body>
    <h1>FixedColumns 锁定列</h1>      

    <div style="padding-bottom:5px;">        
                    
        <input type="button" value="取消锁定" onclick="unfixColumns()"/>
        <input type="button" value="锁定列" onclick="fixColumns()"/>
        
    </div>
    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:280px;" allowResize="true"
        url="../data/AjaxService.jsp?method=SearchEmployees"  idField="id"
        frozenStartColumn="0" frozenEndColumn="1" 
    >
        <div property="columns">
            <!--<div type="indexcolumn">序号</div>    -->            
            <div field="loginname" width="120" headerAlign="center" allowSort="true">员工帐号</div>    
            <div field="name" width="120" headerAlign="center" allowSort="true">姓名</div>    
            <div header="工作信息">
                <div property="columns">
                    <div field="dept_name" width="120">所属部门</div>
                    <div field="position_name" width="100">职位</div>
                    <div field="salary" width="100" allowSort="true">薪资</div>
                </div>
            </div>
            <div field="createtime" width="100" headerAlign="center" dateFormat="yyyy-MM-dd" allowSort="true">创建日期</div>    
            <div header="基本信息">
                <div property="columns">
                    <div field="gender" width="100" renderer="onGenderRenderer">性别</div>
                    <div field="age" width="100" allowSort="true">年龄</div>
                    <div field="birthday" width="100" renderer="onBirthdayRenderer">出生日期</div>
                    <div field="married" width="100" align="center" renderer="onMarriedRenderer">婚否</div>
                    <div field="email" width="100">邮箱</div>
                </div>
            </div>
<!--            <div header="学历信息">
                <div property="columns">
                    <div field="educational_name" width="100">学历</div>
                    <div field="school" width="120">毕业院校</div>
                </div>
            </div> -->                    
        </div>
    </div>
    
    <script type="text/javascript">
        mini.parse();
        

        var grid = mini.get("datagrid1");
        grid.load();
        grid.sortBy("createtime", "desc");


        function unfixColumns() {
            grid.unFrozenColumns();
        }
        function fixColumns() {
            grid.frozenColumns(0, 1);
        }

        /////////////////////////////////////////////////
      
        function onBirthdayRenderer(e) {
            var value = e.value;
            if (value) return mini.formatDate(value, 'yyyy-MM-dd');
            return "";
        }
        function onMarriedRenderer(e) {
            if (e.value == 1) return "是";
            else return "否";
        }
        var Genders = [{ id: 1, text: '男' }, { id: 2, text: '女'}];
        function onGenderRenderer(e) {
            for (var i = 0, l = Genders.length; i < l; i++) {
                var g = Genders[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }
    </script>

    <div class="description">
        <h3>Description</h3>
        
    </div>
</body>
</html>